package com.ruoyi.service.impl;

import java.util.List;

import com.ruoyi.domain.AdvAreas;
import com.ruoyi.mapper.AdvAreasMapper;
import com.ruoyi.service.IAdvAreasService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;

/**
 * Service业务层处理
 *
 * @author ruoyi
 * @date 2024-05-27
 */
@Slf4j
@Service
public class AdvAreasServiceImpl implements IAdvAreasService
{
    @Autowired
    private AdvAreasMapper advAreasMapper;

    /**
     * 查询
     *
     * @param busAreasId 主键
     * @return
     */
    @Override
    public AdvAreas selectAdvAreasByBusAreasId(Long busAreasId)
    {
        return advAreasMapper.selectAdvAreasByBusAreasId(busAreasId);
    }

    @Override
    public List<AdvAreas> selectAdvAreasForOptions(Long busAreasId) {
        return advAreasMapper.selectAdvAreasForOptions(busAreasId);
    }

    /**
     * 查询列表----
     *
     * @param advAreas
     * @return
     */
    @Override
    public List<AdvAreas> selectAdvAreasList(AdvAreas advAreas)
    {
        return advAreasMapper.selectAdvAreasList(advAreas);
    }

    /**
     * 新增
     *
     * @param advAreas
     * @return 结果
     */
    @Override
    public int insertAdvAreas(AdvAreas advAreas)
    {
        return advAreasMapper.insertAdvAreas(advAreas);
    }

    /**
     * 修改
     *
     * @param advAreas
     * @return 结果
     */
    @Override
    public int updateAdvAreas(AdvAreas advAreas)
    {
        return advAreasMapper.updateAdvAreas(advAreas);
    }

    /**
     * 批量删除
     *
     * @param busAreasIds 需要删除的主键
     * @return 结果
     */
    @Override
    public int deleteAdvAreasByBusAreasIds(Long[] busAreasIds)
    {
        try {
            return advAreasMapper.deleteAdvAreasByBusAreasIds(busAreasIds);
        }catch (DataIntegrityViolationException e){
            log.error("地址删除失败{}",e);
            throw new RuntimeException("请先删除关联数据");
        }
    }

    /**
     * 删除信息
     *
     * @param busAreasId 主键
     * @return 结果
     */
    @Override
    public int deleteAdvAreasByBusAreasId(Long busAreasId)
    {
        try {
            return advAreasMapper.deleteAdvAreasByBusAreasId(busAreasId);
        }catch (DataIntegrityViolationException e){
            log.error("地址删除失败{}",e);
            throw new RuntimeException("请先删除关联数据");
        }
    }
}
